<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>体格检查</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">		
		<link rel="stylesheet" href="css/mui.min.css">
		<link rel="stylesheet" type="text/css" href="css/mui.picker.min.css" />
		<link rel="stylesheet" href="css/grandeHealth.css">
		<style>
			.mui-table-view .mui-table-view-cell span{float: right;margin-right: 20px;}
			.mui-navigate-right:after, .mui-push-left:after, .mui-push-right:after{font-size: 20px;}
		</style>
	</head>

	<body>
		<!--<header>class="mui-bar mui-bar-nav" style="display: block;height: 64px;padding-top:20px">
      		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
      		<button id="submit" style="float: right;">保存</button>
	    </header>-->
		
		<div class="mui-content">
			<ul class="mui-table-view">
          		<li id="tiwenPicker" class="mui-table-view-cell">
					<a class="mui-navigate-new mui-navigate-right" href="javascript:;">
			            <label>体温：</label>
			            <span id="tiwen"></span>
		           </a>
				</li>
				<li id="xinlvPicker" class="mui-table-view-cell">
					<a class="mui-navigate-new mui-navigate-right" href="javascript:;">
			            <label>心率：</label>
			            <span id="xinlv"></span>
		           </a>
				</li>
				<li id="xueyaPicker" class="mui-table-view-cell">
					<a class="mui-navigate-new mui-navigate-right" href="javascript:;">
			            <label>血压：</label>
			            <span id="xueya"></span>
		           </a>
				</li>
				<li id="weightPicker" class="mui-table-view-cell">
					<a class="mui-navigate-new mui-navigate-right" href="javascript:;">
			            <label>体重：</label>
			            <span id="weight"></span>
		           </a>
				</li>
				<li id="xuetangPicker" class="mui-table-view-cell">
					<a class="mui-navigate-new mui-navigate-right" href="javascript:;">
			            <label>血糖：</label>
			            <span id="xuetang"></span>
		           </a>
				</li>
				<li id="xueyangPicker" class="mui-table-view-cell">
					<a class="mui-navigate-new mui-navigate-right" href="javascript:;">
			            <label>血氧：</label>
			            <span id="xueyang"></span>
		           </a>
				</li>
	 		</ul>
		</div>
		
		<script src="js/jquery-1.7.2.min.js"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/mui.picker.min.js"></script>
		<script src="js/grandeHealth.js"></script>
		<!--公共js-->
		<script src="js/medicalRecord.js"></script>	
		<script>
			
			(function($, doc) {
				
				$.init();
				var _getParam = function(obj, param) {
				        	
					return obj[param] || '';
				};
				
				/*清除*/
				var _qingchu = function(result,dom){
								
					var cancel = dom.querySelector('.mui-poppicker-btn-cancel');
					var cancelParent = cancel.parentNode;
					var  oA = doc.createElement('div');
					oA.className = 'shanchu mui-btn mui-poppicker-btn-cancel';
					oA.innerHTML = '清除';
						
					if(result.innerText != ''){
						
						cancelParent.insertBefore(oA,cancelParent.childNodes[0]);
						cancelParent.removeChild(cancel);
						dom.querySelector('.shanchu').addEventListener('tap', function(event) {
							result.innerText = '';
							dom.querySelector('.mui-poppicker-header').parentNode.classList.remove("mui-active");
							
							var parent = document.getElementsByTagName("body")[0]
							var child = doc.querySelector('.mui-backdrop');
							parent.removeChild(child);
	
							if(oA.innerHTML = '清除'){
								cancelParent.insertBefore(cancel,cancelParent.childNodes[0]);
								cancelParent.removeChild(oA);
							}
						})
					}
				}
				
				$.ready(function() {
					
					/*
	                 * 体温
	                 */
	                var tiWen = function(x,y,z){
					
					  	/*单数*/
						var shrink = [];        	
				    	for (var i = 0; i < 10;i ++) {
				    		
			    			var value = {};
				    		value["text"] = "" + i + "";
				    		shrink.push(value);
				    	}
				    	
				    	/*整数*/
						var diastole = [];          	
				    	for (var i = 35;i < 44; i ++) {
				    		
				    		var value = {};
				    		value["text"] = "" + i + "";
				    		value["children"] = shrink;
				    		diastole.push(value);
				    	}
				    	
						var picker = new $.PopPicker({
							layer: 2
						});
						
						picker.setData(diastole);
						/*指定位置*/
						//userResult.innerText="37.0℃";
						picker.pickers[0].setSelectedIndex(2);
						picker.pickers[1].setSelectedIndex(0);
						var showUserPickerButton = doc.getElementById(x);
						var userResult = doc.getElementById(y);
						
						showUserPickerButton.addEventListener('tap', function(event) {
							
							/*清除*/
							var dom = doc.getElementsByClassName('mui-poppicker')[0];
							_qingchu(userResult,dom);
							picker.show(function(items) {
								
								shrink = _getParam(items[0], 'text');
								diastole = _getParam(items[1], 'text');
								userResult.innerText = shrink + '.'+ diastole + '°C';
								
								//return false;返回 false 可以阻止选择框的关闭
							});
						}, false);
					}
					tiWen('tiwenPicker','tiwen');
					document.querySelector('.mui-poppicker-body').lastChild.querySelector('.mui-pciker-rule').innerHTML = '.';
					/*==============体温=======================*/
					
					/*
	                 * 心率
	                 */
	                var xinLv = function(x,y,z){
					
					  	/*整数*/
						var shrink = [];        	
				    	for (var i = 30; i < 221;i ++) {
				    		
			    			var value = {};
				    		value["text"] = "" + i + "";
				    		shrink.push(value);
				    	}
				    	
						var picker1 = new $.PopPicker({
							layer: 1
						});
						
						picker1.setData(shrink);
						/*指定位置*/
						//userResult.innerText="60次/分";
						picker1.pickers[0].setSelectedIndex(30);
						var showUserPickerButton = doc.getElementById(x);
						var userResult = doc.getElementById(y);
						
						showUserPickerButton.addEventListener('tap', function(event) {
							
							/*清除*/
							var dom = doc.getElementsByClassName('mui-poppicker')[1];
							_qingchu(userResult,dom);
							picker1.show(function(items) {
								
								shrink = _getParam(items[0], 'text');
								userResult.innerText = shrink + '次/分';
							});
						}, false);
						
					}
					xinLv('xinlvPicker','xinlv');
					/*==============心率=======================*/
					
					/*
	                 * 血压
	                 */
					var shuzhang = function(x,y,z){
					
					  	/*收缩压*/
						var shrink = [];        	
				    	for (var i = 30; i < 221;i ++) {
				    		
			    			var value = {};
				    		value["text"] = "" + i + "";
				    		shrink.push(value);
				    	}
				    	
				    	/*舒张压*/
						var diastole = [];          	
				    	for (var i = 30;i < 221; i ++) {
				    		
				    		var value = {};
				    		value["text"] = "" + i + "";
				    		value["children"] = shrink;
				    		diastole.push(value);
				    	}
				    	
						var picker2 = new $.PopPicker({
							layer: 2
						});
						
						picker2.setData(diastole);
						/*指定位置*/
						//userResult.innerText="120/80mmHg";
						picker2.pickers[0].setSelectedIndex(90);
						picker2.pickers[1].setSelectedIndex(50);
						var showUserPickerButton = doc.getElementById(x);
						var userResult = doc.getElementById(y);
						
						showUserPickerButton.addEventListener('tap', function(event) {
							
							/*清除*/
							var dom = doc.getElementsByClassName('mui-poppicker')[2];
							_qingchu(userResult,dom);
							picker2.show(function(items) {
								
								shrink = _getParam(items[0], 'text');
								diastole = _getParam(items[1], 'text');
								userResult.innerText = shrink + '/'+ diastole + 'mmHg';
							});
						}, false);
						
					}
					shuzhang('xueyaPicker','xueya');
					/*==============血压=======================*/
					
					/*
	                 * 体重
	                 */
	                var Weight = function(x,y,z){
					
					  	/*整数*/
						var shrink = [];        	
				    	for (var i = 3; i < 251;i ++) {
				    		
			    			var value = {};
				    		value["text"] = "" + i + "";
				    		shrink.push(value);
				    	}
				    	
						var picker3 = new $.PopPicker({
							layer: 1
						});
						
						picker3.setData(shrink);
						/*指定位置*/
//						userResult.innerText="60kg";
						picker3.pickers[0].setSelectedIndex(57);
						var showUserPickerButton = doc.getElementById(x);
						var userResult = doc.getElementById(y);
						
						showUserPickerButton.addEventListener('tap', function(event) {
							
							/*清除*/
							var dom = doc.getElementsByClassName('mui-poppicker')[3];
							_qingchu(userResult,dom);
							picker3.show(function(items) {
								
								shrink = _getParam(items[0], 'text');
								userResult.innerText = shrink + 'kg';
							});
						}, false);
						
					}
					Weight('weightPicker','weight');
					/*==============体重=======================*/
					
					/*
	                 * 血糖
	                 */
	                var sugar = function(x,y,z){
					
					  	/*单数*/
						var shrink = [];        	
				    	for (var i = 0; i < 10;i ++) {
				    		
			    			var value = {};
				    		value["text"] = "" + i + "";
				    		shrink.push(value);
				    	}
				    	
				    	/*整数*/
						var diastole = [];          	
				    	for (var i = 1;i < 20; i ++) {
				    		
				    		var value = {};
				    		value["text"] = "" + i + "";
				    		value["children"] = shrink;
				    		diastole.push(value);
				    	}
				    	
						var picker = new $.PopPicker({
							layer: 2
						});
						
						picker.setData(diastole);
						/*指定位置*/
						//userResult.innerText="6.0mmol/L";
						picker.pickers[0].setSelectedIndex(5);
						picker.pickers[1].setSelectedIndex(0);
						
						var showUserPickerButton = doc.getElementById(x);
						var userResult = doc.getElementById(y);
						
						showUserPickerButton.addEventListener('tap', function(event) {
							
							/*清除*/
							var dom = doc.getElementsByClassName('mui-poppicker')[4];
							_qingchu(userResult,dom);
							picker.show(function(items) {
								
								shrink = _getParam(items[0], 'text');
								diastole = _getParam(items[1], 'text');
								userResult.innerText = shrink + '.'+ diastole + 'mmol/L';
							});
						}, false);
						
					}
					sugar('xuetangPicker','xuetang');
					/*==============血糖=======================*/
					
					/*
	                 * 血氧
	                 */
	                var Oxygen = function(x,y,z){
					
					  	/*单数*/
						var shrink = [];        	
				    	for (var i = 60; i < 101;i ++) {
				    		
			    			var value = {};
				    		value["text"] = "" + i + "";
				    		shrink.push(value);
				    	}
				    	
						var picker = new $.PopPicker({
							layer: 1
						});
						
						picker.setData(shrink);
						/*指定位置*/
						//userResult.innerText="98%";
						picker.pickers[0].setSelectedIndex(38);
						
						var showUserPickerButton = doc.getElementById(x);
						var userResult = doc.getElementById(y);
						
						showUserPickerButton.addEventListener('tap', function(event) {
							
							/*清除*/
							var dom = doc.getElementsByClassName('mui-poppicker')[5];
							_qingchu(userResult,dom);
							picker.show(function(items) {
								
								shrink = _getParam(items[0], 'text');
								userResult.innerText = shrink + '%';
							});
						}, false);
						
					}
					Oxygen('xueyangPicker','xueyang');
					/*==============血氧=======================*/
					
				});	
				
			})(mui, document);
			
			/*
			 *获取数据
			 */
			(Tiwen == '°C') ? tiwen.html('') : tiwen.html(Tiwen);
			(Xinlv == '次/分') ? xinlv.html('') : xinlv.html(Xinlv);
			(Xueya == 'mmHg') ? xueya.html('') : xueya.html(Xueya);
			(Weight == 'kg') ? weight.html('') : weight.html(Weight);
			(Xuetang == 'mmol/L') ? xuetang.html('') : xuetang.html(Xuetang);
			(Xueyang == '%') ? xueyang.html('') : xueyang.html(Xueyang);
			
			/*
			 *保存
			 */
			mui("body").on("tap", "#submit", function() {
				
				window.localStorage.setItem('tiwen',tiwen.html())
				window.localStorage.setItem('xinlv',xinlv.html())
				window.localStorage.setItem('xueya',xueya.html())
				window.localStorage.setItem('weight',weight.html())
				window.localStorage.setItem('xuetang',xuetang.html())
				window.localStorage.setItem('xueyang',xueyang.html())
			})
		</script>
	</body>
</html>


